package com.molichuxing.services.infrastructure.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.molichuxing.services.infrastructure.convertor.Convert;
import com.molichuxing.services.infrastructure.dao.UserPayeeMapper;
import com.molichuxing.services.infrastructure.dto.request.create.UserPayeeCreateDto;
import com.molichuxing.services.infrastructure.dto.request.modify.UserPayeeModifyDto;
import com.molichuxing.services.infrastructure.dto.response.UserPayeeDto;
import com.molichuxing.services.infrastructure.service.UserPayeeService;

/**
 * 用户退款信息service
 * 
 * @author zoumingyu
 * @date 2020年2月26日
 *
 */
@Service("userPayeeService")
public class UserPayeeServiceImpl implements UserPayeeService {
	private static final Logger logger = LoggerFactory.getLogger(UserPayeeServiceImpl.class);

	@Autowired
	private UserPayeeMapper userPayeeMapper;

	/**
	 * 获取用户退款信息
	 * 
	 * @param userId
	 *            用户id
	 * @return
	 */
	@Override
	public UserPayeeDto getUserPayee(Integer userId) {
		return Convert.toUserPayeeDto(userPayeeMapper.getByUserId(userId));
	}

	/**
	 * 新增用户退款信息
	 * 
	 * @param crateDto
	 * @return
	 */
	@Override
	public Boolean create(UserPayeeCreateDto createDto) {
		return userPayeeMapper.create(Convert.toUserPayeeBean(createDto)) > 0 ? true : false;
	}

	/**
	 * 修改用户退款信息
	 * 
	 * @param modifyDto
	 * @return
	 */
	@Override
	public Boolean modify(UserPayeeModifyDto modifyDto) {
		return userPayeeMapper.modifyByUserId(Convert.toUserPayeeBean(modifyDto)) > 0 ? true : false;
	}
}
